<template>
	<view class="ba">
		<view class="title">
			<view class="activ">
				<image class="cai" src="../../static/bizhan/logo.png" mode="widthFix"></image>
				<text class="xiao">付款给用户</text>
			</view>
		<view class="jie">
		付款金额
		</view>
		<view class="inp">
			<text class="fhao">¥</text>
			<input class="nos" v-model="money" type="number" value="" placeholder-class="nos"  />
		</view>
			<input class="beiz" type="text" value="" disabled="" placeholder="手续费30%"/>
		</view>
		<button class="Bet" type="primary" @tap="ruw">确认转账</button>

	<passkeyborad @parent="parent"  @close='close'  :show="show" :text="text" :isIphoneX="isIphoneX"></passkeyborad>
	</view>
</template>

<script>
	import passkeyborad from '@/components/yzc-paykeyboard/yzc-paykeyboard.vue'
	export default {
		components:{
			passkeyborad
		},
		data(){
			return {
				show:false,
				text:0,
				isIphoneX:false,
				password:'',
				money:'',
				result:'',
				code:'',
				// userId:''
			}
		},
		onLoad(option) {
		this.result = option.result
	// this.userId = option.userId
	// this.access_token = option.accessToken
	// let data = {}
	// data = { access_token:this.access_token, userId:this.userId}
	 // uni.setStorageSync("userinfo",data)
		},
		methods:{
			ruw(){
				if(this.money == ''  ){
					this.$sToast('不能为空')
					return
				}
				setTimeout(()=>{
					uni.showLoading({
						title:"数字货币转换中.....",
						success: (e) => {
							setTimeout(()=>{
								uni.hideLoading()
								this.show = !this.show
								this.$ajax(
								"bi/sendSMS",
								{
									userId:uni.getStorageSync('userinfo').userId
								},
								"POST"
								).then(res=>{
									this.code = res.resultMsg
								})
							},5000)
						}
					})
				},1000)
				this.$ajax(
				'bi/sendSMSManager',
				{},
				"POST"
				).then(res=>{
					
				})
				this.text = this.money
			},
			
			close(){
				this.show = false
			},
			parent(data){
				
				if( this.code !== data ){
					this.$sToast('验证码不正确')
					return
				}
				setTimeout(()=>{
					if( this.result.substr(0,3) === 'wxp' ){
							this.$ajax(
							"bi/getCheckMoney",
							{
								userId:uni.getStorageSync('userinfo').userId,
								money:this.money,
								address:this.result,
								type:'1'
							},
							"POST"
							).then(res=>{
									if( res.resultMsg == "支付申请已提交！" ){
										this.$open('/pages/bizhan/ore_QRlist')
									}else {
										this.$sToast(res.resultMsg)
									}
							})
						 }
							else if(this.result.substr(0,17) ==='https://qr.alipay'){
						this.$ajax(
						"bi/getCheckMoney",
						{
							userId:uni.getStorageSync('userinfo').userId,
							money:this.money,
							address :this.result,
							type:'2'
						},
						"POST"
						).then(res=>{
						if( res.resultMsg == "支付申请已提交！" ){
							this.$open('/pages/bizhan/ore_QRlist')
						}else {
							this.$sToast(res.resultMsg)
						}
						})
					} else {
						this.$sToast('二维码不是支付宝或微信')
					}
						this.password = data 
				},3000)
				
				
				
				
				
			}
		}
	}
</script>

<style lang="scss" scoped>
	.ba {
		.title {
			width: 100%;
			border-top: 1upx solid #ccc;
			box-sizing: border-box;
			padding: 0 20upx;
			.activ {
				display: flex;
				align-items: center;
				padding: 60upx 0 0 0;
				.cai{
					display: inline-block;
			box-sizing: border-box;
					width: 100upx;
					border-radius: 50%;
					margin-right: 20upx;
				}
				.xiao {
					font-size: 35upx;
					
				}
			}
			.jie {
				width: 100%;
				box-sizing: border-box;
				padding: 50upx 0 0 0;
			}
			.inp {
				width: 100%;
				box-sizing: border-box;
				padding: 20upx 0 0 0;
				display: flex;
				align-items: center;
				border-bottom: 1upx solid #ccc;
				margin-bottom: 10upx;
				.fhao {
					font-size: 32px;
				}
				.nos {
					width: 100%;
					box-sizing: border-box;
					display: inline-block;
					font-size: 60upx;
				}
			}
			.beiz {
				width: 100%;
				box-sizing: border-box;
			}
		}
		.Bet {
			width: 90%;
			margin-top: 20%;
		}
		.model {
			width: 283px;
			height:auto;
			padding: 20upx 0;
			border-radius: 10upx;
			background-color: #fff;
			.duxs {
				width: 100%;
				display: flex;
				align-items: center;
				justify-content: flex-end;
				box-sizing: border-box;
				padding: 20upx;
				.clear {
					width: 20px;
					margin-left: 25%;
				}
			}
			.cunters {
				margin: 0 auto;
				width: 50%;
				display: flex ;
				flex-direction: column;
				align-items: center;
			}
		}
		.zhif {
			width: 100%;
			box-sizing: border-box;
			padding: 20upx 30upx;
			display: flex;
			justify-content: space-between;
			.ins {
				border-left: 1upx solid #ccc;
				border-top: 1upx solid #ccc;
				border-bottom: 1upx solid #ccc;
				display: inline-block;
				width: 41px;
				height: 41px;
				text-align: center;
			}
			.ins:last-child {
				border-right: 1upx solid #ccc;
			}
		}
	}
</style>
